package com.goldenautumn.prefabricate.business.entity

import android.os.Parcel
import android.os.Parcelable
import com.goldenautumn.prefabricate.utils.getToken
import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.annotations.Expose
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName
import com.luck.picture.lib.entity.LocalMedia
import kotlinx.serialization.serializer
import qncx.external.common.room.table.UserInfo
import qncx.external.common.utils.Parcelizer
import java.io.Serializable
import java.util.Locale
import java.lang.reflect.Type

data class BasicPage<T>(
    var list: BasicList<T>? = null

)

data class BasicList<T>(
    var total: Int = 0,
    var per_page: Int = 0,
    var current_page: Int = 0,
    var last_page: Int = 0,
    var data: MutableList<T> = ArrayList(),
)

data class BasicPageParams(
    var page: Int? = 1,
    var size: Int? = 20
)

open class BasicQueryParams(
    var s: String,
    var token: String = getToken()
)

data class HomeTabVo(
    var index:String,
    var name:String,
    var data:MutableList<HomeItemDataVo>? = null
)

data class LoginParams(
    var mobile: String? = null,
    var code: String? = null,
)

data class HomeDataVo(
    var items:MutableList<HomeItemVo>? = null
)

data class HomeItemVo(
    var name:String? = null,
    var type:String? = null,
    var style:HomeStyle? = null,
    var data:JsonElement? = null,
    var brand:List<HomeTabVo>? = null,
)

data class HomeStyle (
    var display:String
)

data class HomeItemDataVo(
    var imgUrl:String? = null,
    var goodsId:String? = null,
    var goods_id:String? = null,
    var linkUrl:String? = null,
    var text:String? = null,
    var color:String? = null,
    var goods_name:String? = null,
    var selling_point:String? = null,
    var image:String? = null,
    var goods_image:String? = null,
    var goods_price:String? = null,
    var line_price:String? = null,
    var categoryId:String? = null,
) : Parcelable {

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(p0: Parcel, p1: Int) {
        Parcelizer.encodeToParcel(serializer(), p0, this)
    }


    companion object CREATOR : Parcelable.Creator<HomeItemDataVo> {
        override fun createFromParcel(parcel: Parcel): HomeItemDataVo {
            return Parcelizer.decodeFromParcel(serializer(), parcel)
        }

        override fun newArray(size: Int): Array<HomeItemDataVo?> {
            return arrayOfNulls(size)
        }
    }
}

data class OrderGoodsInfoVO(
    var goods_id: Int? = null,
    var goods_name: String? = null,
    var spec_sku_id: String? = null,
    var selling_point: String? = null,
    var category_id: Int? = null,
    var order_goods_id: Int? = null,
    var spec_type: Int? = null,
    var deduct_stock_type: Int? = null,
    var goods_sort: Int? = null,
    var goods_price: String? = null,
    var delivery_id: Int? = null,
    var is_points_gift: Int? = null,
    var itemType: Int? = null,
    var is_points_discount: Int? = null,
    var is_enable_grade: Int? = null,
    var is_alone_grade: Int? = null,
    var alone_grade_equity: Int? = null,
    var is_ind_dealer: Int? = null,
    var dealer_money_type: Int? = null,
    var first_money: String? = null,
    var second_money: String? = null,
    var third_money: String? = null,
    var goods_min_price: String? = null,
    var goods_max_price: String? = null,
    var goods_sales: Int? = null,
    var goods_image: String? = null,
    var content: String? = null,
    var goods_sku: GoodsSkuVo? = null,
    var image: FileImageVo? = null,
    var sku: MutableList<GoodsSkuVo>? = null,
    var goods_multi_spec: GoodsMultiSpec? = null,
    var total_num: Int? = null,
    var goods_attr: String? = null,
)


data class OrderDetailsReq(
    var order:OrderDetailsInfoVo? = null
)

data class GoodsDetailsReq(
    var detail:GoodsInfoVO? = null
)

data class GoodsInfoVO(
    var goods_id: Int? = null,
    var goods_name: String? = null,
    var selling_point: String? = null,
    var category_id: Int? = null,
    var spec_type: Int? = null,
    var deduct_stock_type: Int? = null,
    var goods_sort: Int? = null,
    var delivery_id: Int? = null,
    var is_points_gift: Int? = null,
    var itemType: Int? = null,
    var is_points_discount: Int? = null,
    var is_enable_grade: Int? = null,
    var is_alone_grade: Int? = null,
    var alone_grade_equity: Int? = null,
    var is_ind_dealer: Int? = null,
    var dealer_money_type: Int? = null,
    var first_money: String? = null,
    var second_money: String? = null,
    var third_money: String? = null,
    var goods_min_price: String? = null,
    var goods_max_price: String? = null,
    var goods_sales: Int? = null,
    var goods_image: String? = null,
    var content: String? = null,
    var goods_sku: GoodsSkuVo? = null,
    var image: MutableList<FileImageVo>? = null,
    var sku: MutableList<GoodsSkuVo>? = null,
    var goods_multi_spec: GoodsMultiSpec? = null,
    var total_num: Int? = null,
    var goods_attr: String? = null,
)

data class GoodsMultiSpec(
    var spec_attr:MutableList<GoodsSpecPVo>? = null,
    var spec_list:MutableList<SpecPriceListItem>? = null
)

data class SpecPriceListItem(
    var spec_sku_id:Int? = null,
    var form:SpecPriceListItemFrom? = null,
)

data class SpecPriceListItemFrom(
    var goods_price:String? = null
)

data class GoodsSkuVo(
    var goods_sku_id: Int? = null,
    var goods_id: Int? = null,
    var spec_sku_id: String? = null,
    var image_id: Int? = null,
    var goods_no: String? = null,
    var goods_price: String? = null,
    var line_price: String? = null,
    var stock_num: Int? = null,
    var goods_sales: Int? = null,
    var goods_weight: String? = null,
    var goods_attr: String? = null,
):Serializable

data class GoodsSpecPVo(
    var group_id:Int? = null,
    var group_name:String? = null,
    var spec_items:MutableList<GoodsSpecVo>? = null,
)

data class GoodsSpecVo(
    var item_id:Int? = null,
    var spec_value:String? = null,
    var goods_price:String? = null
)

data class CarGoodsInfoVO(
    var goods_id: Int? = null,
    var goods_name: String? = null,
    var goods_image: String? = null,
    var isCheck: Boolean = false,
    var goods_sku: GoodsSkuVo? = null,
    var total_num: Int = 1,
)

data class OrderMenuInfoVo(
    var type: String? = null,
    var title: Int? = null,
    var icon: Int? = null,
    var count: Int = 0,
)

data class AddressCreateParams(
    var name:String? = null,
    var phone:String? = null,
    var region:String? = null,
    var detail:String? = null,
    var address_id:Int? = null,
    var is_default:Int? = null,
    var s:String? = null,
    var token:String? = null,
)

data class AddressResp(
    var list:MutableList<AddressInfoVo>? = null,
    var default_id:Int? = null,
)

data class AddressDetailsResp(
    var detail:AddressInfoVo? = null
)

data class ImageModelResp(
    var file_id:String? = null,
    var file_path:String? = null
)

data class AddressInfoVo(
    var address_id:Int? = null,
    var name:String? = null,
    var phone:String? = null,
    var region:AddressRegion? = null,
    var detail:String? = null,
    var isDefault:Boolean? = false,
):Serializable

data class AddressRegion(
    var province:String? = null,
    var city:String? = null,
    var region:String? = null,
):Serializable

data class OrderListReqParams(
    var status:String,
    var size:Int = 20,
    var page:Int = 1,
)

data class OrderListResp<T>(
    var list:BasicList<T>? = null
)

data class OrderDetailsResp(
    var order: String? = null,
)

data class OrderInfoVo(
    var id: String? = null,
    var status: String? = null,
    var order_id: String? = null,
    var order_no: String? = null,
    var total_price: String? = null,
    var order_price: String? = null,
    var coupon_id: Int? = null,
    var coupon_money: String? = null,
    var points_money: String? = null,
    var create_time: String? = null,
    var points_num: Int? = null,
    var pay_price: String? = null,
    var pay_type: OrderKeyValue? = null,
    var pay_status: OrderKeyValue? = null,
    var receipt_status: OrderKeyValue? = null,
    var pay_time: Long? = null,
    var receipt_time: Long? = null,
    var delivery_time: Long? = null,
    var express_price: String? = null,
    var order_status: OrderKeyValue? = null,
    var delivery_status: OrderKeyValue? = null,
    var goods: List<OrderGoodsInfoVO>? = null,
)

data class OrderKeyValue(
    var text: String? = null,
    var value: String? = null,
)


data class LanguageInfoVo(
    var title:String,
    var language:String,
    var locale: Locale,
    var type:String,
)

data class UserInfoReqResult(
    var userInfo:UserInfoResult? = null,
    var orderCount:OrderCount? = null,
    var menus:MutableList<UserMenuVo>? = null,
)

data class LoginReqResult(
    var user_id:String? = null,
    var token:String? = null,
    var nickName:String? = null,
    var avatarUrl:String? = null,
)

data class UserInfoResult(
    var user_id :Long? = null,
    var nickName :String? = null,
    var open_id :String? = null,
    var mobile :String? = null,
    var avatarUrl :String? = null,
    var gender :String? = null,
    var country :String? = null,
    var province :String? = null,
    var city :String? = null,
    var address_id :Int? = null,
    var address_default :AddressInfoVo? = null,
    var grade :String? = null,
    var is_bind_mobile :Int? = 0,
    var is_bind_wx :Int? = 0,
    var pay_money :String? = null,
)

data class OrderCount(
    var payment:Int = 0,
    var received:Int = 0,
    var comment:Int = 0,
)

data class UserMenuVo(
    var name:String? = null,
    var img:Int? = null,
    var icon:String? = null,
    var type:String? = null
)

data class FileImageVo(
    var id:Int? = null,
    var file_path:String? = null,
):Serializable

data class SpecSelectInfo(
    var position:Int = -1,
    var count:String = "1"
)

data class PaymentMethodVo(
    var value:String,
    var icon:Int,
    var title:String,
)

 data class AddCarGoodsParams(
    var goods_id:String,
    var goods_num:String,
    var goods_sku_id:String,
    var s: String,
    var token: String = getToken()
)

data class CarDataList(
    var goods_list:MutableList<CarGoodsInfoVO>
)

data class RegionTreeVo(
    var id:Int? = null,
    var level:Int? = null,
    var name:String? = null,
    var city:List<CityTreeVo>? = null,
)

data class CityTreeVo(
    var id:Int? = null,
    var level:Int? = null,
    var pid:Int? = null,
    var name:String? = null,
    var region:List<AcrTreeVo>? = null,
)
data class AcrTreeVo(
    var id:Int? = null,
    var level:Int? = null,
    var pid:Int? = null,
    var name:String? = null,
)


data class CarPreviewInfo(
    var goods_list:List<GoodsInfoVO>? = null,
    var order_total_num:Int? = 0,
    var address:AddressInfoVo? = null,
    var order_total_price:String? = null,
    var order_price:String? = null,
    var order_pay_price:String? = null,
    var express_price:String? = null,
    var coupon_money:Int? = null,
)

data class OrderDetailsInfoVo(
    var id: String? = null,
    var status: String? = null,
    var order_id: String? = null,
    var order_no: String? = null,
    var total_price: String? = null,
    var order_price: String? = null,
    var coupon_id: Int? = null,
    var coupon_money: String? = null,
    var points_money: String? = null,
    var create_time: String? = null,
    var points_num: Int? = null,
    var pay_price: String? = null,
    var pay_type: OrderKeyValue? = null,
    var pay_status: OrderKeyValue? = null,
    var receipt_status: OrderKeyValue? = null,
    var pay_time: Long? = null,
    var receipt_time: Long? = null,
    var delivery_time: Long? = null,
    var express_price: String? = null,
    var order_status: OrderKeyValue? = null,
    var delivery_status: OrderKeyValue? = null,
    var delivery_type: OrderKeyValue? = null,
    var goods: List<OrderGoodsInfoVO>? = null,
    var address: AddressInfoVo? = null,
)

data class TypeInfoVo(
    var category_id:String,
    var name:String,
)

data class TypeGoodsResp(
    var list: MutableList<TypeInfoVo>?
)

data class SearchParams(
    var categoryID:String? = null,
    var search:String? = null,
    var sortType:String? = null,//all(默认排序) sales（销量）price（价格）
    var sortPrice:String? = null,//是否降序
    var isSpecial:String? = null,//特殊分类查询
)

data class ExpressResp(
  var express:ExpressInfo? = null
)

data class ExpressInfo(
  var express_name:String? = null,
  var express_no:String? = null,
  var list:MutableList<ExpressInfoVo>? = null,
)

data class ExpressInfoVo(
  var time:String? = null,
  var context:String? = null,
  var ftime:String? = null,
  var areaCode:String? = null,
  var areaName:String? = null,
  var status:String? = null,
)

data class ExpressItem(
  var icon:Int? = null,
  var statusName:String? = null,
  var items:List<ExpressInfoVo>? = null,
)

data class ImageSelectVo(
    var type:Int,
    var img:LocalMedia? = null
)

data class ApplyRefundGoods(
    var goods_id:Int? = null,
    var goods_image:String? = null,
    var goods_name:String? = null,
    var goods_sku:GoodsSkuVo? = null,
    var total_num:Int? = null,
):Serializable

data class  ApplyRefundType(
    var type:Int,
    var title:String,
)

data class  RefundOrderInfoVo(
    var order_refund_id:Int? = null,
    var order_goods_id:Int? = null,
    var order_id:Int? = null,
    var type:OrderKeyValue? = null,
    var is_agree:OrderKeyValue? = null,
    var status:OrderKeyValue? = null,
    var apply_desc:String? = null,
    var refuse_desc:String? = null,
    var create_time:String? = null,
    var order_goods:RefundOrderGoodsInfo? = null,
)

data class RefundOrderGoodsInfo(
    var image:FileImageVo? = null,
    var goods_name:String? = null,
    var goods_id:Int? = null,
    var goods_attr:String? = null,
    var goods_price:String? = null,
    var goods_sku_id:Int? = null,
    var total_num:Int? = null,
)

data class RefundOrderDetailsReq(
    var detail:RefundOrderInfoVo? = null
)

data class WechatToken(
    var access_token:String? = null,
    var openid:String? = null,
    var scope:String? = null,
    var unionid:String? = null,
)

data class LanguageInfo(
    var language_content:String? = null,
    var language_alias:String? = null,
    var language:String? = null,
)

data class TabInfoVo(
    var icon:String? = null,
    var title:String? = null
)